{template 'public/headers'}
{template 'public/comhead'}
<link rel="stylesheet" type="text/css" href="../hyb_o2o/template/public/ygcss.css">
<style type="text/css">
    .yg5_key>div{float: left;line-height: 34px;}

    .store_td1{height: 45px;}

    .store_list_img{width: 60px;height: 60px;}

    .yg5_tabel{border-color: #e5e5e5;outline: 1px solid #e5e5e5;text-align: center;}

    .yg5_tr2>td{padding: 15px;border: 1px solid #e5e5e5;}

    .yg5_tr1>td{

        border: 1px solid #e5e5e5;
        background-color: #FAFAFA;

        font-weight: bold;

    }

    .yg5_btn{background-color: #EEEEEE;color: #333;border: 1px solid #E4E4E4;border-radius: 6px;width: 100px;height: 34px;}
    .check_img{width: 45px;height: 45px;}
    .ygrow{margin-top: 20px;}
    .yghuise{background-color: grey;color: white;}
    .yghuise:hover{background-color: grey;color: white;}
    .detail_box{width: 400px;padding: 20px 100px;position: fixed;left: 50%;top: 50%;transform: translate(-50%,-50%);background: #fff;font-size: 14px;text-align: center;z-index: 5;display: none}
    .detail_box>div>div{
        margin-bottom: 20px;
    }
    .detail_box .left{width: 70px;}
    
</style>
<ul class="nav nav-tabs">
    <span class="ygxian"></span>
    <div class="ygdangq">当前位置:</div>    
    <li {if $op == 'display'} class="active" {/if}><a href="{php echo $this->createWebUrl2('dlistoreyuangong', array('id'=>$storeid,'uid'=>$uniacid,'op'=>'display'))}">门店员工列表</a></li>
    <li {if $op == 'post'} class="active" {/if}><a href="{php echo $this->createWebUrl2('dlistoreyuangong', array('id'=>$storeid,'uid'=>$uniacid,'op'=>'post'))}">添加门店员工</a></li>
</ul>
{if $op =="display"}
<div class="main">
    <div class="panel panel-default">
        <div class="panel-body">
        <form action="" method="post" class="col-md-4">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="hyb_o2o" />
            <input type="hidden" name="do" value="dlistoreyuangong" />
            <input type="hidden" name="op" value="display" />
            <div class="input-group" style="width: 300px">
                <input type="text" name="keywords" class="form-control" placeholder="请输入员工名称">
                <span class="input-group-btn">
                    <input type="submit" class="btn btn-default" name="submit" value="查找"/>
                </span>
            </div>
            <input type="hidden" name="token" value="{$_W['token']}"/>
        </form>
    </div>
</div>
<div class="panel panel-default">
    <div class="panel-heading">门店员工列表</div>
        <div class="panel-body" style="padding: 0px 15px;">
                <div class="row">
                <form id="form1" action="" method="post">
                    <table class="yg5_tabel col-md-12" >
                        <tr class="yg5_tr1" style="line-height:  50px;">
                            <td>
                                <input type="checkbox"  onclick="var ck = this.checked;$(':checkbox').each(function(){this.checked = ck});" name=''>
                                <span class="store_inp">全选</span>
                            </td>
                            <td>id</td>
                            <td>员工名称</td>
                            <td>员工头像</td>
                            <td>性别</td>
                            <td>年龄</td>
                            <td>员工openid</td>
                            <td>员工联系电话</td>
                            <td>服务状态</td>
                            <td>审核状态</td>
                            <td>操作</td>
                        </tr>
                        {loop $list $row}
                        <tr class="yg5_tr2" style="line-height:  50px;">
                            <td >
                                <input type="checkbox" value="{$row['y_id']}" name="deleteall[]">
                            </td>
                            <td >{$row['y_id']}</td>
                            <td >{$row['y_name']}</td>
                            <td >
                                {if strpos($row['y_thumb'],"http")===false}
                                <img class="store_list_img" src="{media $row['y_thumb']}" alt="" width="100px" height="100px" />
                                {else}
                                <img class="store_list_img" src="{$row['y_thumb']}" alt="" width="100px" height="100px" />
                                {/if}
                            </td>
                            <td >{$row['y_sex']}</td>
                            <td >{$row['y_age']}</td>
                            <td ">{$row['y_openid']}</td>
                            <td >{$row['y_telphone']}</td>
                            <td >
                                {if $row['y_typs']=="空闲中"}
                                <span style="border:1px solid ;color: blue">{$row['y_typs']}</span>
                                {elseif $row['y_typs']=="服务中"}
                                <span  style="border:1px solid ;color: green">{$row['y_typs']}</span>
                                {elseif $row['y_typs']=="请假中"}
                                <span style="border:1px solid ;color: red">{$row['y_typs']}</span>
                                {/if}
                            </td>
                            <td>{$row['y_styles']}</td>
                            <td>
                                {if $row['y_styles']=='待审核'}
                                <a href="{php echo $this->createWebUrl2('dlistoreyuangong', array('y_id' => $row['y_id'],'y_styles'=>'审核通过','storeid'=>$storeid,'uid'=>$uniacid,'op'=>'save'))}" class="storespan btn btn-xs">
                                    <span class="fa fa-user" style="margin-right: 0px"></span>
                                    <span class="bianji">审核通过
                                        <span class="arrowdown"></span>
                                    </span>
                                </a>
                                {/if}
                                <a href="{php echo $this->createWebUrl2('dlistoreyuangong', array('y_id' => $row['y_id'],'id'=>$storeid,'uid'=>$uniacid,'op'=>'post'))}" class="storespan btn btn-xs">
                                    <span class="fa fa-pencil"></span>
                                    <span class="bianji">编辑
                                        <span class="arrowdown"></span>
                                    </span>
                                </a>
                                <a href="{php echo $this->createWebUrl2('dlistoreyuangong', array('y_id' => $row['y_id'],'id'=>$storeid,'uid'=>$uniacid,'op'=>'delete'))}" class="storespan btn btn-xs">
                                    <span class="fa fa-trash-o"></span>
                                    <span class="bianji">删除
                                        <span class="arrowdown"></span>
                                    </span>
                                </a>
                            </td>
                        </tr>
                        {/loop}
                        <tr>
                            <td>
                                <input class="btn btn-primary" type="submit" value="全删" name="delsubmit" style="height: 30px;text-align: right;">
                            </td>
                        </tr>
                    </table>
                    </form>
                </div>
            </div>
    </div>
</div>
<div class="text-right we7-margin-top">
     {$pager}
</div>
<script type="text/javascript">
     $('#form1').submit(function(){
        if($(":checkbox[name='deleteall[]']:checked").size() > 0){
            return confirm('删除后不可恢复，您确定删除吗？');
        }
        return false;
    });
</script>
{/if}
{if $op == "post"}
<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <div class="panel panel-default ygdefault">
            <div class="panel-heading wyheader">
                添加员工
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">员工名称</label>
                <div class="col-sm-9">
                    <input type="text" name="y_name" value="{$items['y_name']}" class="form-control" placeholder="请输入员工名称" />
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">员工联系电话</label>
                <div class="col-sm-9">
                    <input type="text" name="y_telphone" value="{$items['y_telphone']}" class="form-control" placeholder="请输入员工联系电话" />
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">员工性别</label>
                <div class="col-sm-9">
                    <input type="radio" name="y_sex"  value="男" {if $items['y_sex'] == '男'} checked{/if} />男
                    <input type="radio" name="y_sex"  value="女" {if $items['y_sex'] == '女'} checked{/if} />女
                </div>
            </div>
            <div class="form-group" style="margin-top: 20px">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">员工年龄</label>
                <div class="col-sm-9">
                    <input type="text" name="y_age" value="{$items['y_age']}" class="form-control" placeholder="请输入员工年龄" />
                </div>
            </div>
            {if empty($y_id)}
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color: red">*员工openid</label>
                <div class="col-sm-9">
                    <select name="y_openid"  class="form-control">
                        <option value="">--请选择--</option>
                        {loop $openid $item}
                        <option value="{$item['openid']}" {if $item['openid']==$items["y_openid"]}selected{/if} >{$item['u_name']}----{$item['openid']}</option>
                        {/loop}
                    </select>
                </div>
            </div>
            {/if}
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">员工头像</label>
                <div class="col-sm-9">
                    {php echo tpl_form_field_image('y_thumb', $items['y_thumb'])}
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color: red">*技能</label>               
                <div class="col-sm-9">
                    <input type="text" name="y_jineng" value="{$items['y_jineng']}" data-jineng="{$fwtypess}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" disabled="" autocomplete="off" style="margin-bottom: 20px;">
                    <input type="hidden" name="y_jineng" value="{$items['y_jineng']}" >
                    <style type="text/css">
                        .label_1,.label_2{padding: 5px 10px;border: 1px solid #999;color: #999;margin-right: 10px;display: inline-block;;margin-bottom: 10px;}
                        .label_1.choose,.label_2.choose{border-color: red;color: red;}
                    </style>
                    <div>
                        {loop $fwtypes $item}
                        {if strpos($items['y_jineng'],$item)===false}
                        <span class="label_1">{$item}</span> 
                        {else}
                        <span class="label_1 choose">{$item}</span> 
                        {/if}                    
                        {/loop}
                    </div>
                    
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label" style="color: red">*服务区域</label>

                <div class="col-sm-9">
                    <input type="text" name="y_fwqy" value="{$items['y_fwqy']}" data-diqus="{$diquss}" class="form-control ng-pristine ng-untouched ng-valid ng-empty"  placeholder="" disabled="" autocomplete="off" style="margin-bottom: 20px;">
                    <input type="hidden" name="y_fwqy" value="{$items['y_fwqy']}" >
                    <div>
                        {loop $diqus $item}
                        {if strpos($items['y_fwqy'],$item)===false}
                        <span class="label_2">{$item}</span>
                        {else}
                        <span class="label_2 choose">{$item}</span>
                        {/if}
                        {/loop}
                    </div>
                    <script type="text/javascript">
                        var values_list=$("input[name=y_jineng]").data("jineng");
                        var fwqy_list=$("input[name=y_fwqy]").data("diqus");
                        console.log(values_list)
                        console.log(fwqy_list)
                        if ($("input[name=y_jineng]").val().length>0) {
                            var values=$("input[name=y_jineng]").val().split(",");
                        }else{
                            var values=[];
                        }
                        if ($("input[name=y_fwqy]").val().length>0) {
                            var fwqy=$("input[name=y_fwqy]").val().split(",");
                        }else{
                            var fwqy=[];
                        }

                        
                        $(".label_1").click(function(){
                            if($(this).hasClass("choose")){
                                $(this).removeClass("choose");
                                var text=$(this).text();
                                var index;
                                for (var i = 0; i < values.length; i++) {
                                    if(values[i]==text){
                                        index=i
                                    }
                                }
                                values.splice(values.indexOf( text ),1);
                                
                            }else{
                                $(this).addClass("choose");
                                values.push($(this).text())
                                // $("input[name=y_jineng]").val(values);
                            }
                            $("input[name=y_jineng]").val(values);
                        })
                        $(".label_2").click(function(){
                            if($(this).hasClass("choose")){
                                $(this).removeClass("choose");
                                var text=$(this).text();
                                var index;
                                for (var i = 0; i < fwqy.length; i++) {
                                    if(fwqy[i]==text){
                                        index=i
                                    }
                                }
                                fwqy.splice(fwqy.indexOf( text ),1);
                                
                            }else{
                                $(this).addClass("choose");
                                fwqy.push($(this).text())
                                // $("input[name=y_jineng]").val(values);
                            }
                            $("input[name=y_fwqy]").val(fwqy);
                        })
                    </script>
                </div>
            </div>
            <div class="form-group">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">员工状态</label>
                <div class="col-sm-9">
                    <input type="radio" name="y_typs"  value="空闲中" {if $items['y_typs'] == '空闲中'} checked{/if} />空闲中
                    <input type="radio" name="y_typs"  value="服务中" {if $items['y_typs'] == '服务中'} checked{/if} />服务中
                    <input type="radio" name="y_typs"  value="请假中" {if $items['y_typs'] == '请假中'} checked{/if} />请假中
               </div>
            </div> 
            <div class="form-group" style="margin-top: 20px">
                <label class="col-xs-12 col-sm-3 col-md-2 control-label">分成比例</label>
                <div class="col-sm-9">
                    <input type="text" name="y_choucheng" value="{$items['y_choucheng']}" class="form-control" placeholder="请输入小数" />
                </div>
            </div>
        <div class="form-group" style="margin-top: 20px;">
            <input type="submit" name="submit" value="提交" class="btn col-lg-3" style="color: white;background-color: #44ABF7;"/>
            <input type="hidden" name="token" value="{$_W['token']}" />
        </div>
    </form>
</div>

{/if}
<script type="text/javascript">
    $(function(){
        $("#frame-0").show();
        $("#yframe-0").addClass("wyactive");
    })
</script>
{template "common/footer"}